﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyOrder.aspx.cs" Inherits="WebApplication1.MyOrder" MasterPageFile="~/masterpage/User.Master" %>





<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <%--Begin Loading ajax section--%>
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"  >
        <ProgressTemplate>
            <div id="divProgress" style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                <div class="center">

                    <img alt="" src="images/loading.gif" />
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
          <div id="divProgress"  style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;display:none">
                <div class="center">

                    <img alt="" src="images/loading.gif" />
                </div>
            </div>
    <%--End Loading ajax section--%>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" >
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="dp"  />
            <asp:AsyncPostBackTrigger ControlID="lsvOrders" />
        </Triggers>
        <ContentTemplate>
            <div id="divContainer" class="container-fluid">
                <div class="control-group col-md-12">
                    <!-- Alert Message -->
                    <asp:Panel ID="divMessage" runat="server" class="alert alert-danger  alert-dismissible" Visible="False" role="alert">
                        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <asp:Label ID="lblMessage" runat="server" Text="">
                         
                        </asp:Label>
                    </asp:Panel>
                    <fieldset>
                        <legend>My Order</legend>
                    </fieldset>



                    <asp:ListView ID="lsvOrders" runat="server" OnItemCommand="lsvOrders_ItemCommand" OnPagePropertiesChanging="lsvOrders_PagePropertiesChanging">
                        <EmptyDataTemplate>
                            No orders
                        </EmptyDataTemplate>
                        <LayoutTemplate>
                            <table id="itemPlaceholderContainer" runat="server" border="0" class="table table-hover table-bordered">
                                <tr runat="server" class="info">

                                    <th runat="server">Order Id </th>

                                    <th runat="server">Created Date</th>
                                    <th runat="server">Pickup Time</th>
                                    <th runat="server">Cancel?</th>
                                    <th runat="server">Cancel Order</th>

                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>

                            </table>
                        </LayoutTemplate>

                        <ItemTemplate>
                            <tr class="success">
                                <td>
                                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Id") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lblPrice" runat="server" Text='<%# Eval("CreatedDate") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("PickupDateTime") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lblCancel" runat="server" Text='<%# Convert.ToInt16(Eval("IsCancel")) == 1 ? "Yes" : "No" %>' />
                                </td>
                                <td style="text-align: center">

                                    <asp:LinkButton ID="btnCancelOrder" runat="server" CommandName="CancelOrder" CommandArgument='<%# Eval("Id") %>' ClientIDMode="AutoID">[x]</asp:LinkButton>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="5">
                                    <div class="centered container-fluid">
                                        <asp:ListView ID="lsvOrderDetails" runat="server" DataSource='<%# ((System.Collections.Generic.HashSet<Business.fos_orderdetails>)Eval("fos_orderdetails")).ToArray() %>'>
                                            <LayoutTemplate>
                                                <table id="itemPlaceholderContainer" runat="server" border="0" class="table table-striped table-condensed center-table" style="width: 80%">
                                                    <tr runat="server">

                                                        <th runat="server">Food
                                                        </th>
                                                        <th runat="server">Quantity
                                                        </th>
                                                        <th runat="server">Price
                                                        </th>


                                                    </tr>
                                                    <tr id="itemPlaceholder" runat="server">
                                                    </tr>

                                                </table>
                                            </LayoutTemplate>
                                            <ItemTemplate>
                                                <tr style="">
                                                    <td>
                                                        <asp:Label ID="lblName" runat="server" Text='<%# Eval("FoodName") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("FoodQuantity") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblPrice" runat="server" Text='<%# Eval("FoodPrice") %>' />
                                                    </td>


                                                </tr>
                                            </ItemTemplate>

                                        </asp:ListView>

                                    </div>

                                </td>

                            </tr>


                        </ItemTemplate>

                        <AlternatingItemTemplate>
                            <tr class="warning">
                                <td>
                                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Id") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lblPrice" runat="server" Text='<%# Eval("CreatedDate") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("PickupDateTime") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lblCancel" runat="server" Text='<%# Convert.ToInt16(Eval("isCancel")) == 1 ? "Yes" : "No" %>' />
                                </td>
                                <td style="text-align: center">

                                    <asp:LinkButton ID="btnCancelOrder" runat="server" CommandName="CancelOrder" CommandArgument='<%# Eval("Id") %>'  ClientIDMode="AutoID">[x] </asp:LinkButton>
                                </td>

                            </tr>
                            <tr>
                                <td colspan="5">
                                    <div>
                                        <asp:ListView ID="lsvOrderDetails" runat="server" DataSource='<%# Eval("fos_orderdetails") %>'>
                                            <LayoutTemplate>
                                                <table id="itemPlaceholderContainer" runat="server" border="0" class="table table-striped table-condensed center-table" style="width: 80%">
                                                    <tr runat="server">

                                                        <th runat="server">Food
                                                        </th>
                                                        <th runat="server">Quantity
                                                        </th>
                                                        <th runat="server">Price
                                                        </th>


                                                    </tr>
                                                    <tr id="itemPlaceholder" runat="server">
                                                    </tr>

                                                </table>
                                            </LayoutTemplate>
                                            <ItemTemplate>
                                                <tr style="">
                                                    <td>
                                                        <asp:Label ID="lblName" runat="server" Text='<%# Eval("FoodName") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("FoodQuantity") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblPrice" runat="server" Text='<%# Eval("FoodPrice") %>' />
                                                    </td>


                                                </tr>
                                            </ItemTemplate>

                                        </asp:ListView>

                                    </div>

                                </td>

                            </tr>


                        </AlternatingItemTemplate>
                    </asp:ListView>

                    <%--       <asp:DataPager ID="DataPager1" runat="server" PageSize="5"  PagedControlID="lsvOrders">
                                                                <Fields>
                                                                    <asp:NumericPagerField />
                                                                 
                                                                </Fields>
                                                            </asp:DataPager>--%>

                    <asp:DataPager ID="dp" runat="server" PagedControlID="lsvOrders" ClientIDMode="Inherit">
                        <Fields>
                            <asp:NumericPagerField />

                        </Fields>
                    </asp:DataPager>
                </div>

            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

      <script type="text/javascript">
          // Get the instance of PageRequestManager.
          var prm = Sys.WebForms.PageRequestManager.getInstance();
          // Add initializeRequest and endRequest
          prm.add_initializeRequest(prm_InitializeRequest);
          prm.add_endRequest(prm_EndRequest);

          // Called when async postback begins
          function prm_InitializeRequest(sender, args) {
              // get the divImage and set it to visible
              var panelProg = $get('divProgress');
              panelProg.style.display = '';
              // reset label text
             <%-- var lbl = $get('<%= this.lblText.ClientID %>');
                 lbl.innerHTML = '';--%>

                 // Disable button that caused a postback
                 $get(args._postBackElement.id).disabled = true;
             }

             // Called when async postback ends
             function prm_EndRequest(sender, args) {
                 // get the divImage and hide it again
                 var panelProg = $get('divProgress');
                 panelProg.style.display = 'none';

                 // Enable button that caused a postback
                 $get(sender._postBackSettings.sourceElement.id).disabled = false;
             }
         </script>
</asp:Content>


